<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: SunKai
  Date: 14-11-6
  Time: 上午10:15
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <link type="text/css" rel="stylesheet" href="/static/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="/static/bootstrap/css/bootstrap-table.css">
    <script type="text/javascript" src="/static/jquery-2.1.0.min.js"></script>
    <script type="text/javascript" src="/static/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="/static/bootstrap/js/bootstrap-table.js"></script>
    <title>度假屋房型管理</title>
    <script type="text/javascript">
        function addHouseInfo(guid) {
            location.href = "/house/info/form/" + guid;
        }
        function addBuildingType() {
            var houseBaseGuid = $("#houseBaseGuid").val();

            location.href = "/house/houseType/form/" + houseBaseGuid;
        }
        function delhouseType(guid) {
            $.ajax({
                url: '/house/houseType/delBuildingType',
                type: 'post',
                data: {buildingTypeGuid: guid},
                success: function () {
                    location.reload();
                }
            })
        }
        function backHouseBase() {
            location.href = "/house/houseBase/list/1";
        }
    </script>
</head>
<body>
<button type="button" class="btn btn-primary" onclick="addBuildingType()" style="display: none">新增</button>
<button type="button" class="btn btn-warning" onclick="backHouseBase()">返回基地列表</button>
<table class="table table-striped">
    <thead>
    <tr>
        <th>名称</th>
        <th>面积</th>
        <th>价格</th>
        <th>房型</th>
        <th>可住人数</th>
        <th>度假屋管理</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${list}" var="iteam">
        <tr>
            <td>${iteam.name}</td>
            <td>${iteam.area}</td>
            <td>${iteam.price}</td>
            <td>${iteam.houseTypeAsString}</td>
            <td>${iteam.personNum}</td>
            <td>
                <c:choose>
                    <c:when test="${iteam.houseName==null}">
                        <input type="hidden" id="houseBaseGuid" value="${houseBaseGuid}"/>
                        <button type="button" class="btn btn-info" onclick="addHouseInfo('${iteam.guid}')">添加度假屋
                        </button>
                    </c:when>
                    <c:otherwise>
                        <a href="/house/info/update/${iteam.houseInfoGuid}">${iteam.houseName}</a>
                    </c:otherwise>
                </c:choose>
            </td>
            <td>
                <a class="btn btn-info" href="/house/houseType/before_update/${iteam.guid}/${houseBaseGuid}">修改</a>
                <a class="btn btn-info" href="/house/info/form/${iteam.guid}">修改度假屋</a>
                <button class="btn btn-info" onclick="delhouseType('${iteam.guid}')">删除</button>
            </td>
        </tr>
    </c:forEach>
    </tbody>
</table>
</body>
</html>
